﻿using ConfExpert.Forms.Base;
using DevExpress.Utils;
using DevExpress.XtraGrid.Controls;
using DevExpress.XtraGrid.Views.Grid;
using Extensions;
using System;
using System.Drawing;

namespace ConfExpert.Forms.Sistem
{
    public partial class Entities : XForm
    {
        public Entities()
        {
            InitializeComponent();
        }

        private void Entities_Load(object sender, EventArgs e)
        {
            

            gridView1.Init("GetEntities");
            gridView1.OptionsFind.FindFilterColumns = "Name";
            gridView1.OptionsFind.FindDelay = 1;
            gridView1.RowCellStyle += gridView1_RowCellStyle;
            gridView1.AddSummary();
            gridView1.BestFitColumns();
            gridView1.MakeReadOnly();

            gridView1.ShowFindPanel();
            find = gridView1.GridControl.Controls.Find("FindControl", true)[0] as FindControl;
            
            this.Shown += Entities_Shown;
        }

        FindControl find;
        void Entities_Shown(object sender, EventArgs e)
        {
            find.FindEdit.Focus();
        }

        void gridView1_RowCellStyle(object sender, RowCellStyleEventArgs e)
        {
            if (e.RowHandle >= 0)
                switch (e.Column.FieldName)
                {
                    case "Id":
                        e.Appearance.Font = new Font(AppearanceObject.DefaultFont, FontStyle.Bold);
                        break;
                }
        }
    }
}
